import {Component, Output} from '@angular/core';
import {MatRadioButton, MatRadioGroup} from "@angular/material/radio";
import {FormsModule} from "@angular/forms";
import {EmergencyButton} from "../../../dto/EmergencyButton";

import {MatButton} from "@angular/material/button";
import {Router} from "@angular/router";
import {StartPageComponent} from "../../start-page/start-page.component";
import {MatDivider} from "@angular/material/divider";
import {NgIf} from "@angular/common";
import {EmergencyType} from "../../../dto/EmergencyType";


@Component({
  selector: 'app-emergency',
  standalone: true,
  imports: [
    MatRadioGroup,
    MatRadioButton,
    FormsModule,
    MatButton,
    StartPageComponent,
    MatDivider,
    NgIf
  ],
  templateUrl: './emergency.component.html',
  styleUrl: './emergency.component.scss'
})
export class EmergencyComponent {
  lawyerAssist = false
  psychologistAssist = false
  emergencyType: EmergencyType[] = [
    {value: 'SEARCH', valueView : EmergencyButton.SEARCH.valueOf()},
    {value: 'HOME_INSPECTION', valueView: EmergencyButton.HOME_INSPECTION.valueOf()},
    {value: 'ORG_INSPECTION', valueView: EmergencyButton.ORG_INSPECTION.valueOf()},
    {value: 'DETENTION', valueView: EmergencyButton.DETENTION.valueOf()},
    {value: 'INTERROGATION_OF_SUSPECTS', valueView: EmergencyButton.INTERROGATION_OF_SUSPECTS.valueOf()},
    {value: 'CONFESSION', valueView: EmergencyButton.CONFESSION.valueOf()},
    {value: 'FAMILY_CONFLICT', valueView: EmergencyButton.FAMILY_CONFLICT.valueOf()},
    {value: 'ROAD_ACCIDENT', valueView: EmergencyButton.ROAD_ACCIDENT.valueOf()},
    {value: 'SERIOUS_ROAD_ACCIDENT', valueView: EmergencyButton.SERIOUS_ROAD_ACCIDENT.valueOf()},
    {value: 'ARREST_PROPERTY', valueView: EmergencyButton.ARREST_PROPERTY.valueOf()},
  ]

  psychologistType = [
    {value: 'PSI_TRAM_SITUATION_ADULT', valueView: 'психотравмирующая ситуация у взрослого'},
    {value: 'PSI_TRAM_SITUATION_CHILD', valueView: 'психотравмирующая ситуация у у подростка'},
    {value: 'PSI_TRAM_SITUATION_FAMILY', valueView: 'психотравмирующая ситуация в семье'},
    {value: 'PTSR', valueView: 'посттравматическое стрессовое расстройство /ПТСР/'}
  ]


  buttonName = [
    'Обыск',
    'Осмотр жилища',
    'Осмотр помещения организации',
    'Задержание',
    'Допрос подозреваемого',
    'Явка с повинной',
    'Семейный конфликт',
    'ДТП',
    'ДТП с тяжкими последствиями',
    'Арест имущества',
    ]
  @Output() selectedButton = ''

  constructor(private router: Router) {
  }

  callAssist() {
    console.log('call lawyer')
    console.log(this.selectedButton)
    let assistType  = ''
    if(this.lawyerAssist) {
      assistType = 'LAWYER'
    }
    if(this.psychologistAssist)  {
      assistType = 'PSYCHOLOGIST'
    }
    console.log(assistType)
    this.router.navigate(['/emg-cabinet'],
      {queryParams: {callType: this.selectedButton, assistType: assistType}}).then(r => {r})
  }

  lawyerAssistance() {
    this.lawyerAssist = !this.lawyerAssist
  }

  psychoAssistance() {
    this.psychologistAssist = !this.psychologistAssist
  }
}
